/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package isd.inventario.modelo;

import isd.general.modelo.GR_Auditoria;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "sttfoh")
@IdClass(ST_ComprosicionFormulaPK.class)
public class ST_ComposicionFormula implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "STTFOH_TIPPRO", nullable = false, length = 6)
    private String tippro;
    @Id
    @Column(name = "STTFOH_ARTCOD", nullable = false, length = 30)
    private String artcod;
    @Id
    @Column(name = "STTFOH_FORMUL", nullable = false, length = 8)
    private String formul;
    
    
    @JoinColumns({
    @JoinColumn(name = "STTFOH_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false, insertable=false, updatable=false),
    @JoinColumn(name = "STTFOH_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne(optional=false)
    private ST_Producto producto;

//    /**
//     *  Formula
//     */
//    @Basic(optional = false)
//    @JoinColumn(name = "STTFOH_FORMUL", referencedColumnName = "STTFOR_FORMUL", nullable = false, insertable=false, updatable=false)
//    @ManyToOne(optional=false)
//    private ST_Fomula formula;

    /**
     * Tipo de formula
     */
    @Column(name = "STTFOH_TIPFOR", nullable = false, length = 1)
    private String tipfor;
    /**
     * Lote optimo
     */
    @Column(name = "STTFOH_LOTOPT", precision = 18, scale = 2)
    private BigDecimal lotopt;

    /*
     * Departamento asociado
     */
    @Column(name = "STTFOH_DEPTOS", length = 6)
    private String deptos;
    /**
     * Factor alternativo 1
     */
    @Column(name = "STTFOH_EXPLOT")
    private Character explot;
    /**
     * Fecha inicio
     */
    @Column(name = "STTFOH_FCHINI")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fchini;
    /**
     * Fecha Fin
     */
    @Column(name = "STTFOH_FCHFIN")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fchfin;

    
    @Column(name = "STTFOH_SECLIN", length = 40)
    private String seclin;
    /**
     * Valor nominal
     */
    @Column(name = "STTFOH_VALNOM", precision = 18, scale = 2)
    private BigDecimal valnom;
    /**
     * Factor Multiplicador
     */
    @Column(name = "STTFOH_FACMUL", precision = 18, scale = 8)
    private BigDecimal facmul;
     /**
     *
     */
    @Column(name = "STTFOH_FACONS", precision = 18, scale = 8)
    private BigDecimal facons;
    /**
     * Factor alternativo 1
     */
    @Column(name = "STTFOH_FACON1", precision = 18, scale = 8)
    private BigDecimal facon1;
    /**
     * Factor alternativo 2
     */
    @Column(name = "STTFOH_FACON2", precision = 18, scale = 8)
    private BigDecimal facon2;
    /**
     * Factor alternativo 3
     */
    @Column(name = "STTFOH_FACON3", precision = 18, scale = 8)
    private BigDecimal facon3;
    /**
     * Observaciones
     */
    @Lob
    @Column(name = "STTFOH_OBSERV", length = 2147483647)
    private String observ;
    /**
     * Generada automáticamente por el sistema
     */
    @Column(name = "STTFOH_GENAUT")
    private Character Genaut;
    /**
     * Tipo de producto aplicación
     */
    @Column(name = "STTFOH_TIPAPL", length = 6)
    private String tipapl;
    /**
     * Codigo de producto aplicación
     */
    @Column(name = "STTFOH_ARTAPL", length = 30)
    private String artapl;

    /*
     * Formular de aplicación
     */
    @Column(name = "STTFOH_FORAPL", length = 8)
    private String forapl;
    /**
     * Objetos asociados
     */
    @Lob
    @Column(name = "STTFOH_OLEOLE", length = 2147483647)
    private String oleole;
    
    @Embedded
    private GR_Auditoria auditoria;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "composicionFormula", fetch=FetchType.LAZY)
    @JoinColumns({
    @JoinColumn(name = "STTFOH_TIPPRO", referencedColumnName = "STTFOI_TIPPRO", nullable = false),
    @JoinColumn(name = "STTFOH_ARTCOD", referencedColumnName = "STTFOI_ARTCOD", nullable = false),
    @JoinColumn(name = "STTFOH_FORMUL", referencedColumnName = "STTFOI_FORMUL", nullable = false)
    })
    private List<ST_ItemComposicionFormula> itemComposicion;

    public ST_ComposicionFormula() {
        
    }

    public ST_ComposicionFormula(String tippro, String artcod, String formul) {
        this.tippro = tippro;
        this.artcod = artcod;
        this.formul = formul;
    }

    
    public String getArtcod() {
        return artcod;
    }

    public void setArtcod(String artcod) {
        this.artcod = artcod;
    }

    public String getFormul() {
        return formul;
    }

    public void setFormul(String formul) {
        this.formul = formul;
    }

    public GR_Auditoria getAuditoria() {
        return auditoria;
    }

    public void setAuditoria(GR_Auditoria auditoria) {
        this.auditoria = auditoria;
    }
    
    public ST_Producto getProducto() {
        return producto;
    }

    public void setProducto(ST_Producto producto) {
        this.producto = producto;
    }

    public String getTippro() {
        return tippro;
    }

    public void setTippro(String tippro) {
        this.tippro = tippro;
    }

    public Character getGenaut() {
        return Genaut;
    }

    public void setGenaut(Character Genaut) {
        this.Genaut = Genaut;
    }

    public String getArtapl() {
        return artapl;
    }

    public void setArtapl(String artapl) {
        this.artapl = artapl;
    }

    public String getDeptos() {
        return deptos;
    }

    public void setDeptos(String deptos) {
        this.deptos = deptos;
    }

    public Character getExplot() {
        return explot;
    }

    public void setExplot(Character explot) {
        this.explot = explot;
    }

    public BigDecimal getFacmul() {
        return facmul;
    }

    public void setFacmul(BigDecimal facmul) {
        this.facmul = facmul;
    }

    public BigDecimal getFacon1() {
        return facon1;
    }

    public void setFacon1(BigDecimal facon1) {
        this.facon1 = facon1;
    }

    public BigDecimal getFacon2() {
        return facon2;
    }

    public void setFacon2(BigDecimal facon2) {
        this.facon2 = facon2;
    }

    public BigDecimal getFacon3() {
        return facon3;
    }

    public void setFacon3(BigDecimal facon3) {
        this.facon3 = facon3;
    }

    public BigDecimal getFacons() {
        return facons;
    }

    public void setFacons(BigDecimal facons) {
        this.facons = facons;
    }

    public Date getFchfin() {
        return fchfin;
    }

    public void setFchfin(Date fchfin) {
        this.fchfin = fchfin;
    }

    public Date getFchini() {
        return fchini;
    }

    public void setFchini(Date fchini) {
        this.fchini = fchini;
    }

    public String getForapl() {
        return forapl;
    }

    public void setForapl(String forapl) {
        this.forapl = forapl;
    }

    public BigDecimal getLotopt() {
        return lotopt;
    }

    public void setLotopt(BigDecimal lotopt) {
        this.lotopt = lotopt;
    }

    public String getObserv() {
        return observ;
    }

    public void setObserv(String observ) {
        this.observ = observ;
    }

    public String getOleole() {
        return oleole;
    }

    public void setOleole(String oleole) {
        this.oleole = oleole;
    }

    public String getSeclin() {
        return seclin;
    }

    public void setSeclin(String seclin) {
        this.seclin = seclin;
    }

    public String getTipapl() {
        return tipapl;
    }

    public void setTipapl(String tipapl) {
        this.tipapl = tipapl;
    }

    public String getTipfor() {
        return tipfor;
    }

    public void setTipfor(String tipfor) {
        this.tipfor = tipfor;
    }

    public BigDecimal getValnom() {
        return valnom;
    }

    public void setValnom(BigDecimal valnom) {
        this.valnom = valnom;
    }

    public List<ST_ItemComposicionFormula> getItemComposicion() {
        return itemComposicion;
    }

    public void setItemComposicion(List<ST_ItemComposicionFormula> itemComposicion) {
        this.itemComposicion = itemComposicion;
    }
    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ST_ComposicionFormula other = (ST_ComposicionFormula) obj;
        if ((this.tippro == null) ? (other.tippro != null) : !this.tippro.equals(other.tippro)) {
            return false;
        }
        if ((this.artcod == null) ? (other.artcod != null) : !this.artcod.equals(other.artcod)) {
            return false;
        }
        if ((this.formul == null) ? (other.formul != null) : !this.formul.equals(other.formul)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 23 * hash + (this.tippro != null ? this.tippro.hashCode() : 0);
        hash = 23 * hash + (this.artcod != null ? this.artcod.hashCode() : 0);
        hash = 23 * hash + (this.formul != null ? this.formul.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "ST_ComposicionFormula{" + "tippro=" + tippro + "artcod=" + artcod + "formul=" + formul + '}';
    }

    

}
